var express = require('express'); //引入框架

var app = express();

var goods = require("./goods.js");
var user = require("./user")
var address = require('./address')

app.all('*', function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,X-Token,x-access-token");
  res.header("Content-Type", "text/json; charset=utf-8")
  next()
})

app.get('/upload/*', function (req, res) {
  res.sendFile(__dirname + "/" + req.url)
})

app.use('/goods', goods.route)
app.use('/user',user.route)
app.use('/address',address.route)

var server = app.listen(8033, function () {
  var host = server.address().address
  var port = server.address().port
  console.log("应用实例，访问地址为 http://%s:%s", host, port)
})